<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>vue选项</title>
</head>
<body>
    <div id="app">
        <input type="text" v-model="msg">
        <span>{{person}}</span>
        <button @click="person.name='洛璃'">点击切换</button>
    </div>
    <script src="../vue2.js"></script>
    <script>
        const vm = new Vue({
            el:'#app',
            data(){
                return{
                    msg: '',
                    person: {
                        name: 'luoli',
                        age: 18
                    }
                }
            },
            methods:{

            },
            computed:{

            },
            watch:{
                person:{
                    handler(newValue,oldValue){//监听回调
                        console.log(newValue,oldValue);
                    },
                    deep: true//开启深度监听
                },
                //简写
                msg() {
                        //msg发生变动则会触发该函数

                },
                // "person.name": function(){

                // }
            }
        })
    </script>
</body>
</html>